var friendsView = Titanium.UI.createView({
	width:'100%',
	height:'100%',
	top:'0%',
	left:'0%',
});

var controlView = Titanium.UI.createView({
	top:'0%',
	//backgroundColor:'#6e9608',
	left:'0%',
	width:'100%',
	height:'100%'
});

var followingButton = Titanium.UI.createButton({
	//backgroundImage:'button.png',
	top:'1%',
	left:'20%',
	width:'30%',
	height:'10%',
	title:'Following',
	font:{
		fontSize:12
	}
});

var followerButton = Titanium.UI.createButton({
	//backgroundImage:'button.png',
	top:'1%',
	left:'50%',
	width:'30%',
	height:'10%',
	title:'Follower',
	font:{
		fontSize:12
	}
});



var titleContainer = Titanium.UI.createView({
	width:'100%',
	height:'5%',
	backgroundColor:'#4e4e4e',
	left:'0%',
	top:'11%'	
});

var titleLabel = Titanium.UI.createLabel({
	text:'Following',
	color:'#fff',
	width:'auto',
	height:'auto'
});
titleContainer.add(titleLabel);
friendsContainer.add(titleContainer);

var followingContainer = Titanium.UI.createView({
	top:'16%',
	left:'0%',
	width:'100%',
	height:'87%',
	//backgroundColor:'red'
});

friendsView.add(followingContainer);
var uId=1;
if(uId==1) {
	var names = Array("MMF","Gawish","e-Gamal","Sharkawy","Tawfiek");
	var places = Array("Home","Alshefaa Hospital","CookDoor Restruant","Alahly Bank","Home","Pyramids","Fifa Cloths","Alwekala");
	var date = Array("2 hours ago","2 days ago","3 days ago","5 days ago","7 days ago","10 days ago","10 days ago","last week");
	var data=Array("elfares102@yahoo.com","+20161645043","Male","@Sayedfathy","@Sayedfathy","elfares102@yahoo.com");
	var description = 'The man who knows himself well';
	var rank = 'mayor';
	var pic = 'user.png';
	var imgs=Array(1,2,3,4,5);
} else {
	var names = Array("MMF","Gawish","e-Gamal","Sharkawy","Tawfiek");
	var places = Array("Alwekala","HTC Bank","Pyramids","Home","Fifa Cloths");
	var date = Array("1 day ago","2 day ago","5 days ago","6 days ago");
	var data=Array("ahmed_ali@yahoo.com","+20166645013","Male","@AhmedAli","@Ahmed_ALi","ahmed_ali@yahoo.com");	
	var description = 'Ahmed Ali Will Rocks Rocks :)';
	var rank = 'fresh';
	var pic='ali.png';
	var imgs=Array(1,2,3,4,5);
}

var rowData = [];
				var alertDialog = Titanium.UI.createAlertDialog({
				    title: 'Delete !!',
				    message: 'Remove this checkin from profile',
				    buttonNames: ['YES','NO']
				});

for (var i = 0; i <names.length; i++) {
var row = Titanium.UI.createTableViewRow({
	height: 'auto',
	width:'100%',
	className:"item "+i,
	id:""+i,
	top:'0%',
	left:'0%'
});
var post_view = Titanium.UI.createView({
	height:'100%', 
	width:'100%',
	layout:'horizontal',
	top:'0%',
	left:'0%',
	//backgroundColor:'blue'
});
			// Create image view to hold profile pic
var av_image = Titanium.UI.createImageView({
	backgroundImage:'images/following/'+imgs[i]+'.jpg', // the image for the image view
	backgroundColor:'#ffcc00',
	top:'10%',
	left:'0%',
	height:'80%',
	width:'20%'
});
post_view.add(av_image);
av_image.addEventListener('click',function(){
	alert("yarab");
});
var name = Titanium.UI.createLabel({
	text:names[i],
	color:'#252525',
	font: {
	fontSize:17
	},
	top:'5%',
	left:'2%',
	width:'auto'
});
post_view.add(name);
			// Create the label to hold the screen name
var AtLabel = Titanium.UI.createLabel({
	text:'@',
	color:'#717171',
	font: {
	fontSize:15
	},
	top:'5%',
	left:'2%'
});
post_view.add(AtLabel);

var placeLabel = Titanium.UI.createLabel({
	text:places[i],
	left:'2%',
	width:'auto',
	top:'5%',
	textAlign:'left',
	color:'#575858',
	font:{fontSize:15}
});
post_view.add(placeLabel);
			// Create the label to hold 
var dateLabel = Titanium.UI.createLabel({
	text:date[i],
	left:'25%',
	bottom:'2%',
	height:'auto',
	width:'auto',
	textAlign:'left',
	color:'#777777',
	font:{fontSize:10}
});
row.add(dateLabel);

// Add the post view to the row
var unfollow = Titanium.UI.createButton({
   	backgroundImage:'images/unfollow.png',
	//backgroundColor:'red',
	bottom:'10%',
	right:'2%',
	width:'auto',
	height:'auto',
	id:""+i
});
row.add(unfollow);		
row.add(post_view);
			// Give each row a class name
row.className = "item"+i;
			// Add row to the rowData array
rowData[i] = row;
post_view.addEventListener('click',function() {
 alert("hello");
});		
unfollow.addEventListener('click',function(e) {
	alertDialog.show();
	deleteRow(e.source.id);
});
}
var tableView = Titanium.UI.createTableView({data:rowData});
followingContainer.add(tableView);	



//====================================================================


var followerContainer = Titanium.UI.createView({
	top:'16%',
	left:'0%',
	width:'100%',
	height:'87%',
	//backgroundColor:'red'
});


//followerContainer.hide();
	var names = Array("Amr Negm","ِAshraf Hamdy","Ragab","Elhelaly","Mustafa","Ayoub");
	var places = Array("HTC Bank","OuBoox","Wifi Center","Pyramids","Home","Gamasa");
	var date = Array("Now","Now","3 hours ago","5 hours ago","2 days ago","10 days ago","2 weeks ago");
	var data=Array("elfares102@yahoo.com","+20161645043","Male","@Sayedfathy","@Sayedfathy","elfares102@yahoo.com");
	var description = 'The man who knows himself well';
	var rank = 'mayor';
	var pic = 'user.png';
	var imgs=Array(1,2,3,4,5,6);
	var followType =Array(1,0,0,1,0);

var rowData = [];
				var alertDialog = Titanium.UI.createAlertDialog({
				    title: 'Delete !!',
				    message: 'Remove this checkin from profile',
				    buttonNames: ['YES','NO']
				});

for (var i = 0; i <names.length; i++) {
var row = Titanium.UI.createTableViewRow({
	height: 'auto',
	width:'100%',
	className:"item "+i,
	id:""+i,
	top:'0%',
	left:'0%'
});
var post_view = Titanium.UI.createView({
	height:'100%', 
	width:'100%',
	layout:'horizontal',
	top:'0%',
	left:'0%',
	//backgroundColor:'blue'
});
			// Create image view to hold profile pic
var av_image = Titanium.UI.createImageView({
	backgroundImage:'images/follower/'+imgs[i]+'.jpg', // the image for the image view
	backgroundColor:'pink',
	top:'10%',
	left:'0%',
	height:'80%',
	width:'20%'
});
post_view.add(av_image);

var name = Titanium.UI.createLabel({
	text:names[i],
	color:'#252525',
	font: {
	fontSize:17
	},
	top:'5%',
	left:'2%',
	width:'auto'
});
post_view.add(name);
			// Create the label to hold the screen name
var AtLabel = Titanium.UI.createLabel({
	text:'@',
	color:'#717171',
	font: {
	fontSize:15
	},
	top:'5%',
	left:'2%'
});
post_view.add(AtLabel);

var placeLabel = Titanium.UI.createLabel({
	text:places[i],
	left:'2%',
	width:'auto',
	top:'5%',
	textAlign:'left',
	color:'#575858',
	font:{fontSize:15}
});
post_view.add(placeLabel);
			// Create the label to hold 
var dateLabel = Titanium.UI.createLabel({
	text:date[i],
	left:'25%',
	bottom:'2%',
	height:'auto',
	width:'auto',
	textAlign:'left',
	color:'#777777',
	font:{fontSize:10}
});
row.add(dateLabel);

// Add the post view to the row
var unfollow = Titanium.UI.createButton({
   	backgroundImage:'images/unfollow.png',
	backgroundColor:'red',
	bottom:'10%',
	right:'2%',
	width:'auto',
	height:'auto',
	id:""+i
});

var followHim = Titanium.UI.createButton({
   	backgroundImage:'images/follow.png',
	backgroundColor:'red',
	bottom:'10%',
	right:'2%',
	width:'auto',
	height:'auto',
	id:""+i
});
if(followType[i]==1) {
	row.add(unfollow);
} else {
	row.add(followHim);
}
		
row.add(post_view);
			// Give each row a class name
row.className = "item"+i;
			// Add row to the rowData array
rowData[i] = row;
			
unfollow.addEventListener('click',function(e) {
	alertDialog.show();
	deleteRow(e.source.id);
});
}
var tableView = Titanium.UI.createTableView({data:rowData});
followerContainer.add(tableView);	

//=====================================================================




controlView.add(followerButton);
controlView.add(followingButton);

friendsView.add(controlView);
friendsContainer.add(friendsView);
Titanium.include('/makan/control/friendsViewHands.js');
